<template>
	<image class="chat-image" mode="widthFix" @click="imageClick" :src="data.content"></image>
</template>

<script>
	export default {
		props: {
			data: String,
			urls: {
				type: Array,
				default: () => []
			}
		},
		methods: {
			imageClick() {
				
				uni.previewImage({
					current: this.getIdx(),
					urls: this.urls.length ? this.urls : [this.data.content]
				});
			},
			getIdx() {
				console.log(this.urls)
				return this.urls.findIndex(url => url === this.data.content) || 0
			}
		}
	}
</script>=n

<style lang="scss">
	.chat-image {
		width: 160px;
		border-radius: 8px;
	}
</style>
